window.onload = function (){
	var w =50,divs,i=1,r,c,l,left,top,style,el,bWidth=5,padding = 5; 
	var tw = (w+bWidth)*3+bWidth+padding*2;
	divs = document.getElementsByTagName('div');
	el = divs[0];
	el.setAttribute('style', ["width:", tw, 'px;',"height:", tw, 'px;'].join(''));
	el.style.width = tw;
	el.style.height = tw;
	l = divs.length;
	for(; i < l; i++){
		style ="";
	    el = divs[i];
		r = Math.floor((i-1)/3);
		c = (i-1)%3;
		left = (w+bWidth)*c+padding;
		top = (w+bWidth)*r+padding;
		style += "margin-left:"+left+"px;margin-top:"+top+"px;";
		el.setAttribute('style', style);
		el.style['margin-left']=left;
		el.style['margin-top']=top;
	}
}
